<template>
  <h3>Child...</h3>
  <p>{{ count }}</p>
  <button @click="update">按钮</button>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Child",
  // props: ['count'],
  // props: {
  //   count: Number,
  // },
  props: {
    count: {
      type: Number,
      required: true,
    },
    setCount: {
      type: Function,
      required: true,
    },
  },
  methods: {
    update() {
      // props数据是只读的，不能直接修改
      // this.count++;
      this.setCount();
    },
  },
});
</script>
